package com.pubinfo.passbook.api.controller.rule;

import com.pubinfo.passbook.common.entity.TRuleDistrict;
import com.pubinfo.passbook.common.model.dto.rule.RuleDistrictParam;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.model.vo.base.MyPage;
import com.pubinfo.passbook.common.service.master.TRuleDistrictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("district/manager")
@Api(tags = "地区管理")
public class TDistrictController {
  
  @Resource
  private TRuleDistrictService districtService;
  
  @PostMapping("save")
  @ApiModelProperty("新增地区")
  public JsonResult<Boolean> saveDistrict(@RequestBody TRuleDistrict district) {
    return JsonResult.success(districtService.saveRuleDistrict(district));
  }
  
  @DeleteMapping("remove")
  @ApiModelProperty("删除地区")
  public JsonResult<String> removeDistrict(String id) {
    return districtService.removeRuleDistrict(id);
  }
  
  @PostMapping("update")
  @ApiModelProperty("更新地区")
  public JsonResult<String> updateDistrict(@RequestBody TRuleDistrict district) {
    return districtService.updateRuleDistrict(district);
  }
  
  @PostMapping("select")
  @ApiModelProperty("查询地区")
  public JsonResult<MyPage<TRuleDistrict>> selectDistrict(@RequestBody RuleDistrictParam param) {
    return JsonResult.success(new MyPage(districtService.selectRuleDistrict(param)));
  }
  
}
